<?php
/**
 * @version $Id$
 * @package    Jmonoslideshow
 * @author     Matthieu BARBE {@link http://www.ccomca.com}
 * @author     Created on 13-June-2010
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport('joomla.application.component.view');

//require helper slideshow
require_once( JPATH_BASE.DS.'components'.DS.'com_jmonoslideshow'.DS.'helpers'.DS.'slideshow.php' );

/**
 * @package		Joomla
 * @subpackage	Jmonoslideshow
 */
class JmonoslideshowViewSlideshow extends JView
{
	function display($tpl = null)
	{
		global $mainframe;
		$app		= JFactory::getApplication();
		$user		= &JFactory::getUser();
		$pathway	= $app->getPathway();;
		$model		= &$this->getModel();

		// Get the parameters of the active menu item
		$menus	= &JSite::getMenu();
		$menu    = $menus->getActive();

		$pparams = $app->getParams();
		
		$this->assignRef('items',	$model->getMedias( $pparams ));
		$this->assignRef('params',		$pparams);
                $this->_prepareDocument();
		
		require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jmonoslideshow'.DS.'library'.DS.'Mobile_Detect.php' );
		$detect = new Mobile_Detect;
		if ($detect->isMobile() || $detect->isTablet()) $tpl = "noflash";
		parent::display($tpl);
	}
        
        /**
	 * Prepares the document
	 */
	protected function _prepareDocument()
	{
		$app		= JFactory::getApplication();
		$menus		= $app->getMenu();
		$pathway	= $app->getPathway();
		$title 		= null;

		// Because the application sets a default page title,
		// we need to get it from the menu item itself
		$menu = $menus->getActive();

		if ($menu) {
			$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
		}
		else {
			$this->params->def('page_heading', JText::_('COM_CONTACT_DEFAULT_PAGE_TITLE'));
		}

		$title = $this->params->get('page_title', '');

		$id = (int) @$menu->query['id'];

		

		if (empty($title)) {
			$title = $app->getCfg('sitename');
		}
		elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
			$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
		}
		elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
			$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
		}

		if (empty($title)) {
			$title = $this->item->name;
		}
		$this->document->setTitle($title);

		
		$this->document->setDescription($this->params->get('menu-meta_description'));
                $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
		

		if ($this->params->get('robots'))
		{
			$this->document->setMetadata('robots', $this->params->get('robots'));
		}

		
	}
	
}
